dimensions = input().split(' ')
n = int(dimensions[0])
m = int(dimensions[1])
dir_horiz = input()
dir_vert = input()
answer = True
if not (dir_horiz[0] == '<' or (dir_vert[0] == '^' and dir_vert[-1] == 'v' and '<' in dir_horiz)):
answer = False
if not (dir_horiz[-1] == '>' or (dir_vert[0] == '^' and dir_vert[-1] == 'v' and '>' in dir_horiz)):
answer = False
if not (dir_vert[0] == 'v' or (dir_horiz[0] == '>' and dir_horiz[-1] == '<' and 'v' in dir_vert)):
answer = False
if not (dir_vert[-1] == '^' or (dir_horiz[0] == '>' and dir_horiz[-1] == '<' and '^' in dir_vert)):
answer = False
if answer:
print("YES")
else:
print("NO")
#include <bits/stdc++.h>
#include<cmath>
#include<algorithm>
#include <unordered_map>
#include<bitset>
#include <unordered_set>
#define Fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define sortvector(v) sort(v.begin(),v.end())
#define sortrvector(v) sort(v.rbegin(),v.rend())
#define loop(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int>
#define Checkk cerr<<".........."
typedef long long ll;
const ll MOD = 1e9 + 7;
using namespace std;
const int N = 20+3;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 };
bool prime[N];
void Sieve()
{
memset(prime, 1, sizeof(prime));
prime[0] = prime[1] = false;
for (int i = 2; i < N; i++) {
if (prime[i]) {
for (ll j = 1ll * i * i; j < N; j += i)
prime[j] = false;
}
}
}
ll binaryexponentialpower(int base, int power)
{
ll result = 1;
while (power > 0) {
if (power & 1)
result *= base;
base *= base;
power /= 2;
}
return result;
}
ll modularbinaryexponentialpower(int base, int power, int mod)
{
ll result = 1;
while (power > 0) {
if (power & 1)
result = (result * base) % mod;
base = ((base % mod) * (base % mod)) % mod;
power /= 2;
}
return result;
}
ll __gcd(ll a, ll b) {
while (b != 0)
{
ll a2 = a;
a = b;
b = a2 % b;
}
return a;
}
int GetDivisors(ll x) {
set<int>s;
for (ll i = 1; i * i <= x; i++) {
if (x % i == 0)
{
s.insert(i);
if (x / i != i)
{
s.insert(x / i);
}
}
}
return s.size();
}
int main() {
Fast
/*freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);*/
int t = 1;
// cin >> t;
while (t--) {
int n;
cin >> n >> n;
string s1; cin >> s1;
string s2; cin >> s2;
string s3 = { s1.front() , s1.back() , s2.front() , s2.back() };
cout << (s3 == "<>v^" || s3 == "><^v" ? "YES" : "NO");
}
}
791. Custom Sort String | 787. Cheapest Flights Within K Stops |
779. K-th Symbol in Grammar | 701. Insert into a Binary Search Tree |
429. N-ary Tree Level Order Traversal | 739. Daily Temperatures |
647. Palindromic Substrings | 583. Delete Operation for Two Strings |
518. Coin Change 2 | 516. Longest Palindromic Subsequence |
468. Validate IP Address | 450. Delete Node in a BST |
445. Add Two Numbers II | 442. Find All Duplicates in an Array |
437. Path Sum III | 436. Find Right Interval |
435. Non-overlapping Intervals | 406. Queue Reconstruction by Height |
380. Insert Delete GetRandom O(1) | 332. Reconstruct Itinerary |
368. Largest Divisible Subset | 377. Combination Sum IV |
322. Coin Change | 307. Range Sum Query - Mutable |
287. Find the Duplicate Number | 279. Perfect Squares |
275. H-Index II | 274. H-Index |
260. Single Number III | 240. Search a 2D Matrix II |